package com.hex.ds.hdrs.cron.dto;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.hex.ds.hdrs.common.excel.ExcelVerifyInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * @Package: com.hex.ds.hdrs.cron.dto
 * @ClassName CronTaskImportDto
 * @Description: 定时任务Excel导入数据对象
 * @Author: wz.li
 * @Date 2023/4/3 11:44
 * @Version v2.0.2
 **/
@Data
public class CronTaskImportDto extends ExcelVerifyInfo {

    @Excel(name = "任务编码 *", orderNum = "1", width = 15)
    @NotBlank(message = "        [任务编码]不能为空")
    @Pattern(regexp = "^[0-9A-Z_|()=>.-]+$", message = "        [任务编码]只能输入大写英文字母、下划线、分隔符或数字及指定符号(=>.-)")
    @Size(max = 100, message = "        [任务编码]长度不能大于100位")
    private String taskCode;

    @Excel(name = "任务名称 *", orderNum = "2", width = 15)
    @NotBlank(message = "        [任务名称]不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9_\\u4e00-\\u9fa5-()=>._\\s*]+$", message = "        [任务名称]不能输入特殊字符")
    @Size(max = 100, message = "        [任务名称]长度不能大于100位")
    private String taskName;

    @Excel(name = "cron表达式 *", orderNum = "3", width = 15)
    @NotBlank(message = "        [cron表达式]不能为空")
    private String cronExpress;

    @Excel(name = "执行脚本命令 *", orderNum = "4", width = 15)
    @NotBlank(message = "        [执行脚本命令]不能为空")
    private String shellPath;

    @Excel(name = "外部参数", orderNum = "5", width = 15)
    private String extParam;

    @Excel(name = "资源数 *", orderNum = "6", width = 15)
    @NotNull(message = "        [资源数]不能为空")
    @Pattern(regexp = "^[1-9]\\d*$", message = "        [资源数]只能输入大于0正整数")
    private String resNum;

    @Excel(name = "指定节点编码", orderNum = "7", width = 15)
    private String appointAgentCode;

    @Excel(name = "是否设置生效日期 *", orderNum = "8", width = 15, replace = {"否_0", "是_1"})
    @NotBlank(message = "        [是否设置生效日期]不能为空")
    @Pattern(regexp = "[01]", message = "        [是否设置生效日期]格式错误，只能输入‘是’或‘否’")
    private String isValidDate;

    @Excel(name = "生效开始日期", orderNum = "9", width = 15, importFormat = "yyyy-MM-dd", databaseFormat = "yyyy-MM-dd",
            exportFormat = "yyyy-MM-dd")
    @Pattern(regexp =  "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|"+
            "((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|"+
            "((0[48]|[2468][048]|[3579][26])00))-02-29)$",
            message = "        [生效开始日期]日期格式不正确，只支持yyyy-MM-dd格式")
    @Size(max = 10, message = "        [生效开始日期]日期格式不正确，长度必须为10位")
    private String taskStDate;

    @Excel(name = "生效结束日期", orderNum = "10", width = 15, importFormat = "yyyy-MM-dd", databaseFormat = "yyyy-MM-dd",
            exportFormat = "yyyy-MM-dd")
    @Pattern(regexp =  "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|"+
            "((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|"+
            "((0[48]|[2468][048]|[3579][26])00))-02-29)$",
            message = "        [生效结束日期]日期格式不正确，只支持yyyy-MM-dd格式")
    @Size(max = 10, message = "        [生效结束日期]日期格式不正确，长度必须为10位")
    private String taskEndDate;

    @Excel(name = "任务状态 *", orderNum = "11", width = 15, replace = {"未发布_0", "启用_1", "停用_2"})
    @NotBlank(message = "        [运行状态]不能为空")
    @Pattern(regexp = "[012]", message = "        [运行状态]格式错误，只能输入‘未发布’、‘启用’、或'停用'")
    private String taskStatus;

    @Excel(name = "预计执行时长（秒）*", orderNum = "12", width = 15)
    @NotBlank(message = "        [预计执行时长]不能为空")
    @Pattern(regexp = "^[+]{0,1}(\\d+)$", message = "        [预计执行时长]只能输入包括0的正整数")
    private String planExecDuration;

    @Excel(name = "超时时长（秒）*", orderNum = "13", width = 15)
    @NotBlank(message = "        [超时时长]不能为空")
    @Pattern(regexp = "^[+]{0,1}(\\d+)$", message = "        [超时时长]只能输入包括0的正整数")
    private String overPlanDuration;

    @Excel(name = "操作 *", orderNum = "14", width = 15, replace = {"新增_A", "更新_U", "删除_D"})
    @NotBlank(message = "        [操作]不能为空")
    @Pattern(regexp = "[AUD]", message = "        [操作]格式错误，只能输入‘新增’、‘更新’、或'删除'")
    private String operation;

    @Excel(name = "任务描述", orderNum = "15", width = 15)
    @Size(max = 100, message = "        [任务描述]长度不能大于60位")
    private String taskDesc;

}
